package top.appx.zsms;

import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by john on 2016/7/16.
 */
public class Config {
    private static Logger Log=Logger.getRootLogger();

    public static String configFilename = "/config.properties";

    public static String zsms_db_url = null;
    public static String zsms_db_username = null;
    public static String zsms_db_password = null;

    static {
        try {
            Properties properties = new Properties();
            InputStream in = Config.class.getResourceAsStream(configFilename);
            properties.load(in);
            in.close();
            Properties zsmsProperties = properties;

            String zsms_file = properties.getProperty("zsms_file");

            if(zsms_file != null){
                Log.debug("装载"+zsms_file);
                zsmsProperties = new Properties();
                InputStream inputStream = null;
                inputStream = Config.class.getResourceAsStream(zsms_file);
                zsmsProperties.load(inputStream);
                inputStream.close();
            }

            zsms_db_url = zsmsProperties.getProperty("zsms_db_url","jdbc:mysql:///smsdb?useUnicode=true&characterEncoding=utf-8");
            zsms_db_username = zsmsProperties.getProperty("zsms_db_username","root");
            zsms_db_password = zsmsProperties.getProperty("zsms_db_password","youotech");
        } catch (IOException e) {
            Log.error("加载配置文件出错",e);
            e.printStackTrace();

        }

    }



}
